<?php
if (!defined('ZZQSS')){
	die("Access Denied");
}

function upload_file($files,$folder)
{
  $file_tyle = $files['type'];
  $file_type_arr = array('image/gif','image/x-png','image/jpg','image/pjpeg');
 if( !in_array($file_tyle,$file_type_arr) )
  {
  		exit('上传的文件类型只能为:png,jpeg,jpg,gif');
  }
  $knamearray = explode( "." , $files["name"] );
  $kname      = $knamearray[count($knamearray)-1];
  $rand_str   = random_filename();
  $file_name  = $rand_str.".".$kname;
  $savepath = "$folder/date_".date('YmdHis')."/"; 
  if( !is_dir($savepath) ) mkdir($savepath);
  $upfile = $savepath.$file_name;
  if( !move_uploaded_file($files['tmp_name'],$upfile) )
  {
   	exit('上传文件失败,请确认你上传的文件类型为png,jpeg,jpg,gif');
  }
  return $upfile;//不要回传值此行可注释掉
}


?>